let express = require('express')
let path = require('path')
let mysql = require('./api/sql')


let app = express()

app.use(express.static('./'))

let login=require('./api/login')
app.use('/login',login)


let  reg=require('./api/reg')
app.use('/reg',reg)

let check=require('./api/user')
app.use('/user',check)



// 设置模板类型
app.set('view engine', 'ejs');
// 设置模板文件目录
app.set('views', path.join(__dirname, './api/template'));


// 使用模块引擎实现服务器渲染
app.get('/userList', async (req, res) => {
    let row = await mysql.query(`select * from user`);
    
    res.render('userlist', { list: row })
})


app.listen(3030,()=>{
    console.log('running port 3030');
    
})